package com.ruoyi.web.controller.cashier;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.system.domain.MemberList;
import com.ruoyi.system.domain.SyTraditionalReservation;
import com.ruoyi.system.domain.vo.MembershipManagementVO;
import com.ruoyi.system.domain.vo.memberDetailVO;
import com.ruoyi.system.dto.MemberDetailUpdateDTO;
import com.ruoyi.system.dto.MemberListDTO;
import com.ruoyi.system.dto.MemberShipDTO;
import com.ruoyi.system.service.MembershipManagementService;
import com.ruoyi.system.util.BaseResponse;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/membership")
@Api(tags = "会员管理")
public class MembershipManagementController extends BaseController {

    @Autowired
    private MembershipManagementService managementService;


    @PostMapping("/list")
    @ApiOperation("会员概览")
    public AjaxResult list(@RequestBody MemberShipDTO memberShipDTO) {
        MembershipManagementVO list = managementService.listOverview(memberShipDTO);
        return AjaxResult.success(list);
    }

    /**
     * 新增会员
     */
    @PostMapping("/add")
    @ApiOperation("新增会员")
    public AjaxResult add(@RequestBody MemberList memberList) {
        Boolean save = managementService.add(memberList);
        return AjaxResult.success(save);
    }

    /**
     * 会员列表
     */
    @PostMapping("/memberList")
    @ApiOperation("会员列表")
    public BaseResponse<IPage<MemberList>> memberList(@RequestBody MemberListDTO memberListDTO) {
        IPage<MemberList> memberListIPage = managementService.memberList(memberListDTO);
        return BaseResponse.success(memberListIPage);
    }

    /**
     * 会员列表 - 会员详情-会员基本信息
     * memberId 会员id
     */
    @GetMapping("/memberList/memberDetail")
    @ApiOperation("会员列表 - 会员详情-会员基本信息")
    public BaseResponse<memberDetailVO> memberDetail(Long id) {
        return BaseResponse.success(managementService.memberDetail(id));
    }

    /**
     * 会员列表 - 会员详情 - 信息修改
     */
    @PostMapping("/memberList/memberDetail/update")
    @ApiOperation("会员列表 - 会员详情 - 信息修改")
    public AjaxResult memberDetailUpdate(@ApiParam("会员详情修改数据") @RequestBody MemberDetailUpdateDTO updateDTO) {
        Boolean aBoolean = managementService.updateMemberList(updateDTO);
        return AjaxResult.success(aBoolean);
    }


}
